<template>
  <div id="driverType">
    <div class="driverIndex_top">
      <p>
        <img src="@/assets/imgs/chezhu_bg.png" />
      </p>
    </div>
    <div class="driverType">
      <ul>
        <!-- <li @click="goIntercity">
                    <p>
                        城际有车车主加入
                        <span>城际出行</span>
                    </p>
                    <h6>城际用车、补贴高、工作轻松</h6>
        </li>-->
        <!-- <li @click="goTaxi">
                    <p>
                        出租车车主加入
                        <span>出租车</span>
                    </p>
                    <h6>在线接单，让您获得更多订单、提升收入</h6>
        </li>-->
        <li @click="goCityCard">
          <p>
            市内车主-带车加入
            <span>市内用车</span>
          </p>
          <h6>拼车模式，订单多多，收入多多</h6>
        </li>
        <li @click="goCityCardNo">
          <p>
            市内车主-无车加入
            <span>市内用车</span>
          </p>
          <h6>拼车模式，订单多多，收入多多</h6>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import '@/assets/svgs/tishi.svg';
import { Icon, Field, FieldItem, InputItem, Toast, Dialog } from 'mand-mobile';
import Loading from '@/components/loading';
import { decryptByDESModeEBC, encryptByDESModeEBC } from '@/common/encrypt';
import Utils from '@/common/pakjUtils';
import http from '@/common/http';
// var Vconsole = require('vconsole');
// var cons = new Vconsole();
export default {
  components: {
    [Icon.name]: Icon,
    [Field.name]: Field,
    [Toast.name]: Toast,
    [InputItem.name]: InputItem,
    [FieldItem.name]: FieldItem
  },
  data() {
    return {
      title: '平安到家车主注册'
    };
  },
  mounted() {},
  methods: {
    // 城际
    // goIntercity() {
    //     window.location.href = 'http://wx.padj.group/intercitydriver/enterpagedriver';
    // },
    // 出租车
    goTaxi() {
      if (this.$route.query.driverphone) {
        var params = {
          driverPhone: this.$route.query.driverphone
        };
        Loading.show();
        http.post('/pakj/txDriver/getTxDriverAuditInfoByPhone', params).then(res => {
          Loading.hide();
          console.log(res.data.data);
          if (res.data.code === '000000') {
            if (JSON.stringify(res.data.data) === '{}') {
              // 第一次注册
              this.$router.push({
                name: 'driverIdentity',
                query: {
                  driverphone: this.$route.query.driverphone,
                  serviceType: '1'
                }
              });
            } else {
              // 注册状态 0 资料未完善 1 审核中 2 审核通过 3 审核失败
              if (res.data.data.auditStatus === '0') {
                this.$router.push({
                  name: 'driverIdentity',
                  query: {
                    driverphone: this.$route.query.driverphone,
                    serviceType: '1',
                    driverid: res.data.data.driverId
                  }
                });
              } else if (res.data.data.auditStatus === '1') {
                // 1 审核中
                this.$router.push({
                  name: 'driverStatus',
                  query: {
                    auditStatus: '1',
                    driverphone: this.$route.query.driverphone
                  }
                });
              } else if (res.data.data.auditStatus === '2') {
                // 2 审核通过
                this.$router.push({
                  name: 'driverStatus',
                  query: {
                    auditStatus: '2',
                    driverphone: this.$route.query.driverphone
                  }
                });
              } else if (res.data.data.auditStatus === '3') {
                // 3 审核失败
                this.$router.push({
                  name: 'driverStatus',
                  query: {
                    auditStatus: '3',
                    type: '2',
                    driverphone: this.$route.query.driverphone,
                    driverid: res.data.data.driverId
                  }
                });
              }
            }
          } else {
            Dialog.alert({
              title: '提示',
              content: res.data.msg,
              confirmText: '确定'
            });
          }
        });
      } else {
        Dialog.alert({
          title: '提示',
          content: '获取不到手机号',
          confirmText: '确定'
        });
      }
    },
    // 市内有车
    goCityCard() {
      this.goCardType('1');
    },
    // 市内无车
    goCityCardNo() {
      this.goCardType('2');
    },
    goCardType(type) {
      if (this.$route.query.driverphone) {
        var params = {
          driverPhone: this.$route.query.driverphone
        };
        Loading.show();
        http.post('pakj/cityDriver/getCityDriverAuditInfoByPhone', params).then(res => {
          Loading.hide();
          console.log(res.data.data);
          if (res.data.code === '000000') {
            if (JSON.stringify(res.data.data) === '{}') {
              // 第一次注册
              if (type === '1') {
                // 市内快车 有车
                this.$router.push({
                  name: 'driverCity',
                  query: {
                    type: '3',
                    driverphone: this.$route.query.driverphone,
                    serviceType: '2',
                    cardType: '1'
                  }
                });
              } else if (type === '2') {
                // 市内快车 无车
                this.$router.push({
                  name: 'driverCity',
                  query: {
                    type: '4',
                    driverphone: this.$route.query.driverphone,
                    serviceType: '2',
                    cardType: '2'
                  }
                });
              }
            } else {
              // 注册状态 1 审核中 2 审核通过 3 审核失败
              if (res.data.data.auditStatus === '1') {
                if (res.data.data.type === '1') {
                  // 已经注册市内有车车主
                  if (type === '1') {
                    // 1 审核中
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '1',
                        driverphone: this.$route.query.driverphone
                      }
                    });
                  } else {
                    Dialog.confirm({
                      icon: 'tishi',
                      content: '您已提交了市内用车-带车加入，您确认需要更改为“无车加入”吗？',
                      confirmText: '确定',
                      cancelText: '取消',
                      onConfirm: () => {
                        sessionStorage['backCity'] = '1';
                        window.location.href =
                          '/driverrecruitment/driverQuickIdentity?type=4&driverphone=' +
                          this.$route.query.driverphone +
                          '&driverid=' +
                          res.data.data.driverId +
                          '&cardType=2' +
                          '&serviceType=2';
                        // this.$router.push({
                        //     name: 'driverQuickIdentity',
                        //     query: {
                        //         type: '4',
                        //         driverphone: this.$route.query.driverphone,
                        //         driverid: res.data.data.driverId,
                        //         cardType: '2',
                        //         serviceType: '2'
                        //     }
                        // });
                      }
                    });
                  }
                } else if (res.data.data.type === '2') {
                  // 已经注册市内无车车主
                  if (type === '2') {
                    // 1 审核中
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '1',
                        driverphone: this.$route.query.driverphone
                      }
                    });
                  } else {
                    Dialog.confirm({
                      icon: 'tishi',
                      content: '您已提交了市内用车-无车加入，您确认需要更改为“带车加入”吗？',
                      confirmText: '确定',
                      cancelText: '取消',
                      onConfirm: () => {
                        sessionStorage['backCity'] = '1';
                        window.location.href =
                          '/driverrecruitment/driverQuickIdentity?type=3&driverphone=' +
                          this.$route.query.driverphone +
                          '&driverid=' +
                          res.data.data.driverId +
                          '&cardType=1' +
                          '&serviceType=2';
                        // this.$router.push({
                        //     name: 'driverQuickIdentity',
                        //     query: {
                        //         type: '3',
                        //         driverphone: this.$route.query.driverphone,
                        //         driverid: res.data.data.driverId,
                        //         cardType: '1',
                        //         serviceType: '2'
                        //     }
                        // });
                      }
                    });
                  }
                }
              } else if (res.data.data.auditStatus === '2') {
                if (res.data.data.type === '1') {
                  // 有车车主注册已通过
                  if (type === '1') {
                    // 2 审核通过
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '2',
                        driverphone: this.$route.query.driverphone
                      }
                    });
                  } else {
                    Dialog.alert({
                      icon: 'tishi',
                      content: '您已经是市内车主，不能再申请了呦！',
                      confirmText: '我知道了'
                    });
                  }
                } else if (res.data.data.type === '2') {
                  if (type === '2') {
                    // 2 审核通过
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '2',
                        driverphone: this.$route.query.driverphone
                      }
                    });
                  } else {
                    Dialog.alert({
                      icon: 'tishi',
                      content: '您已经是市内车主，不能再申请了呦！',
                      confirmText: '我知道了'
                    });
                  }
                }
              } else if (res.data.data.auditStatus === '3') {
                sessionStorage['examineReason'] = res.data.data.auditRemarks;
                if (res.data.data.type === '1') {
                  // 注册市内有车车主审核失败
                  if (type === '1') {
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '3',
                        type: '3',
                        driverphone: this.$route.query.driverphone,
                        driverid: res.data.data.driverId,
                        serviceType: '2',
                        cardType: '1'
                      }
                    });
                  } else {
                    Dialog.confirm({
                      icon: 'tishi',
                      content: '您已提交了市内用车-带车加入，您确认需要更改为“无车加入”吗？',
                      confirmText: '确定',
                      cancelText: '取消',
                      onConfirm: () => {
                        // 市内无车
                        sessionStorage['backCity'] = '1';
                        window.location.href =
                          '/driverrecruitment/driverQuickIdentity?type=4&driverphone=' +
                          this.$route.query.driverphone +
                          '&driverid=' +
                          res.data.data.driverId +
                          '&cardType=2' +
                          '&serviceType=2';
                        // this.$router.push({
                        //     name: 'driverQuickIdentity',
                        //     query: {
                        //         type: '4',
                        //         driverphone: this.$route.query.driverphone,
                        //         driverid: res.data.data.driverId,
                        //         cardType: '2',
                        //         serviceType: '2'
                        //     }
                        // });
                      }
                    });
                  }
                } else if (res.data.data.type === '2') {
                  // 注册市内无车车主审核失败
                  if (type === '2') {
                    this.$router.push({
                      name: 'driverStatus',
                      query: {
                        auditStatus: '3',
                        type: '4',
                        driverphone: this.$route.query.driverphone,
                        driverid: res.data.data.driverId,
                        serviceType: '2',
                        cardType: '2'
                      }
                    });
                  } else {
                    Dialog.confirm({
                      icon: 'tishi',
                      content: '您已提交了市内用车-无车加入，您确认需要更改为“带车加入”吗？',
                      confirmText: '确定',
                      cancelText: '取消',
                      onConfirm: () => {
                        sessionStorage['backCity'] = '1';
                        window.location.href =
                          '/driverrecruitment/driverQuickIdentity?type=3&driverphone=' +
                          this.$route.query.driverphone +
                          '&driverid=' +
                          res.data.data.driverId +
                          '&cardType=1' +
                          '&serviceType=2';
                        // this.$router.push({
                        //     name: 'driverQuickIdentity',
                        //     query: {
                        //         type: '3',
                        //         driverphone: this.$route.query.driverphone,
                        //         driverid: res.data.data.driverId,
                        //         cardType: '1',
                        //         serviceType: '2'
                        //     }
                        // });
                      }
                    });
                  }
                }
              }
            }
          } else {
            Dialog.alert({
              title: '提示',
              content: res.data.msg,
              confirmText: '确定'
            });
          }
        });
      } else {
        Dialog.alert({
          title: '提示',
          content: '获取不到手机号',
          confirmText: '确定'
        });
      }
    }
  }
};
</script>
<style lang="stylus">
p {
  display: block;
  margin-block-start: 0px;
  margin-block-end: 0px;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}

h6 {
  display: block;
  font-size: 22px;
  margin-block-start: 0em;
  margin-block-end: 0em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  font-weight: 400;
}

#driverType {
  height: 100%;

  .driverIndex_top {
    position: relative;
  }

  .driverIndex_top img {
    width: 100%;
    display: block;
  }

  .driverType ul li {
    margin: 0px 54px;
    box-shadow: 0px 2px 4px 0px rgba(217, 221, 240, 1);
    border-radius: 10px;
    height: 136px;
    padding: 0px 20px;
  }

  .driverType ul li p {
    font-size: 32px;
    color: #FF6917;
    font-weight: 600;
    margin-top: 40px;
  }

  .driverType ul li p span {
    float: right;
    background-color: #FF6917;
    width: 130px;
    height: 46px;
    line-height: 46px;
    display: inline-block;
    text-align: center;
    font-size: 24px;
    color: #fff;
    border-radius: 7px;
    font-weight: 400;
  }

  .driverType ul li h6 {
    font-size: 24px;
    color: #666;
    font-weight: 400;
    margin-top: 20px;
  }
}
</style>
